package WeekOne;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.PriorityQueue;
import java.util.Scanner;

/**
 * @Author @fiber-cloud
 * @Date 2025/10/15 6:52
 */
public class DAY03 {
    public static void main1(String[] args) {
        Scanner scanner = new Scanner(System.in);
        //输入一个由若干单词组成的复合词
        String str = scanner.nextLine();
        //将输入的复合词进行拆分
        String[] strs = str.split(" ");
        //构建要简写形式的对象
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < strs.length; i++) {
            sb.append(strs[i].charAt(0)+"");
        }

        //最后输出的结果要全部大写
        System.out.println(sb.toString().toUpperCase());
    }


    public static void main2(String[] args) {
        //读入两个数，n和k
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int x = scanner.nextInt();
        int[] num = new int[n+1];

        //读入n个数
        for (int i = 1; i <= n; i++) {
            num[i] = scanner.nextInt();
        }
        //维护窗口左右边界 要求是最小的窗口，这里一步步缩小
        int left = 1 , right = 1, sum = 0;
        int retLeft = -1, retRight = -1, retLen = n;


        while (right <= n){
            //开始进窗口
            sum += num[right];
            while (sum >= x){
                //开始更新结果
                if (right - left + 1 < retLen){
                    retLeft = left;
                    retRight = right;
                    retLen = right - left +1;
                }
                sum -= num[left++];
            }
            right++;
        }
        System.out.println(retLeft+" "+retRight);
    }

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String[] firstLine = br.readLine().split(" ");
        int n = Integer.parseInt(firstLine[0]);
        int k = Integer.parseInt(firstLine[1]);

        String[] arr = br.readLine().split(" ");
        long[] nums = new long[n];
        long sum = 0;
        // 使用最大堆（优先队列）来存储偶数
        PriorityQueue<Long> maxHeap = new PriorityQueue<>((a, b) -> Long.compare(b, a));

        for (int i = 0; i < n; i++) {
            nums[i] = Long.parseLong(arr[i]);
            sum += nums[i];

            // 如果是偶数，加入最大堆
            if (nums[i] % 2 == 0) {
                maxHeap.offer(nums[i]);
            }
        }

        // 进行最多k次操作
        int operations = 0;
        while (operations < k && !maxHeap.isEmpty()) {
            long current = maxHeap.poll();

            // 计算操作后的值
            long newValue = current / 2;

            // 更新总和：减少的值是 current - newValue
            sum -= (current - newValue);

            // 如果新值仍然是偶数，可以继续操作
            if (newValue % 2 == 0) {
                maxHeap.offer(newValue);
            }

            operations++;
        }

        System.out.println(sum);
    }


}
